Skip to content

fix(hooks): drop a rejected session start before the next turn - #45

Merged
vincentkoc merged 8 commits into
openclaw:mainfrom
SebTardif:fix/session-start-rejection
Oct 1, 2026
Merged

vincentkoc merged 8 commits into
openclaw:mainfrom
SebTardif:fix/session-start-rejection

Conversation

@SebTardif

@SebTardif SebTardif commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Recover turn preparation after a rejected session start, logging the failure once.
  • Keep concurrent prepares behind the same pending start and follow a replacement
    start without deleting its entry. Prevent late completion from restoring ended
    or replaced session context. A persistent owner token prevents older end/reset
    cleanup from removing a replacement, including after its context is consumed.
  • Preserve the original Hermes callback order and synchronous session-start
    enqueue. No callback relocation, public API change, or new lifecycle subsystem.
  • Retain Sebastien Tardif's original contribution and credit.

Compatibility

  • Source apps: Hermes, Claude Code, Codex.
  • Surfaces: session-start hooks and turn preparation.
  • Successful start context is consumed once. Failed starts do not poison later
    turns; session end/reset and distinct sessions remain isolated.
  • No expansion of plugin execution authority or change to decision-hook policy.

Verification

Exact head: 60b6196ff70398ea5cce37d07e32983857312998, based on
e03fb18d70e110826287f7933b976bc7f7bfb6f5.

  • Focused session-start and registered-handler tests: 25 passed.
  • npm run check: 193 tests passed in 12 files.
  • npm run pack:check: 24 files, 290021 unpacked bytes.
  • Independent exact-head review: no actionable introduced defects.
  • Real Python timeout and subsequent context recovery, warning once.
  • Concurrent prepares; replacement during pre-LLM callback; end while waiting.
  • Older end/reset cleanup with replacement still pending or already consumed.
  • Empty replacement does not inherit prior-owner unconsumed context.
  • Real Python session initialization precedes a concurrent turn callback.
  • Successful context consumed once; session isolation/end/reset.
  • README compatibility table, compatibility reference, changelog and credit.
  • Diff scrubbed for private paths, secrets and generated files.

All fixtures use isolated temporary state.

Merge is held at the ClawSweeper gate. Its supported
exact-item review run
failed admission with queue does not advertise enabled manual record/comment-only publication.
The existing verdict belongs to the original head and is not reused as clearance.
The ClawSweeper operator must restore that capability and rerun the failed review,
or a genuine automatic review must publish a verdict for this exact head.

agent_turn_prepare awaited a session_start promise that stayed in the
map after rejection, so every later turn in that session threw. Delete
the entry before awaiting it, and do not rethrow from turn prepare.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 6:12 AM ET / 10:12 UTC (Revision 2).

ClawSweeper review

What this changes

Babelfish recovers turn preparation after failed session starts while preserving concurrent waits, replacement context, and lifecycle cleanup.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: main and v0.1.0 retain the rejected session-start promise. The earlier README finding is resolved, and the pinned head has no actionable introduced defects.

Likely related people: vincentkoc and RomneyDa are routing candidates from prior runtime work.

Priority: P2
Reviewed head: 60b6196ff70398ea5cce37d07e32983857312998

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with production-boundary Python evidence, lifecycle coverage, resolved prior feedback, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The captured exact-head verification and inspected registered-handler fixtures exercise src/index.ts through the real Python bridge: timeout recovery returns context on three later turns with one warning, and concurrent preparation observes initialized state. GitHub confirms successful exact-head execution; raw logs were inaccessible through the artifact redirect. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured exact-head verification and inspected registered-handler fixtures exercise src/index.ts through the real Python bridge: timeout recovery returns context on three later turns with one warning, and concurrent preparation observes initialized state. GitHub confirms successful exact-head execution; raw logs were inaccessible through the artifact redirect. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction and merge result: Read all six introduced files between the pinned main and head. The verified test merge produces the same production changes against its main parent; no base-only work is attributed to this PR.
Current main still needs the repair: Main awaits the stored start promise before deleting it. Rejection skips deletion, leaving subsequent prepares to await the same rejected promise. The PR catches rejection and removes only the matching settled entry.
Released behavior: The v0.1.0 source also contains the unguarded await followed by deletion, so the latest supplied release does not contain this repair.
Findings None None.
Security None None.

How this fits together

Babelfish translates imported plugin lifecycle hooks into OpenClaw callbacks. Session-start results supply context to later agent turns, while session end and reset release runtime resources.

flowchart TD
 A[OpenClaw lifecycle events] --> B[Imported session hooks]
 B --> C[Hermes Python bridge]
 B --> D[Session owner and pending start]
 D --> E[Turn preparation]
 E --> F[Agent context]
 A --> G[End and reset cleanup]
 G --> D
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +40/-10; tests +352/-0 Production growth implements settled-promise and lifecycle ownership guards, with focused recovery and race coverage.

Technical review

Best possible solution:

Retain recovery after settled start failures and owner-guarded lifecycle cleanup without changing callback order or plugin decision policy.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the failure: a rejected session-start promise remains stored because main deletes it only after a successful await. The real-Python timeout fixture exercises that trigger; this read-only review did not execute it locally.

Is this the best way to solve the issue?

Yes, the patch narrowly repairs promise cleanup and replacement ownership while preserving the existing callback sequence, with focused lifecycle coverage and compatibility documentation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e03fb18d70e1.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded imported-hook failure that otherwise prevents later turns in the affected session.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured exact-head verification and inspected registered-handler fixtures exercise src/index.ts through the real Python bridge: timeout recovery returns context on three later turns with one warning, and concurrent preparation observes initialized state. GitHub confirms successful exact-head execution; raw logs were inaccessible through the artifact redirect. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head verification and inspected registered-handler fixtures exercise src/index.ts through the real Python bridge: timeout recovery returns context on three later turns with one warning, and concurrent preparation observes initialized state. GitHub confirms successful exact-head execution; raw logs were inaccessible through the artifact redirect. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge result: Read all six introduced files between the pinned main and head. The verified test merge produces the same production changes against its main parent; no base-only work is attributed to this PR. (src/index.ts:575, 60b6196ff703)
  • Current main still needs the repair: Main awaits the stored start promise before deleting it. Rejection skips deletion, leaving subsequent prepares to await the same rejected promise. The PR catches rejection and removes only the matching settled entry. (src/index.ts:575, e03fb18d70e1)
  • Released behavior: The v0.1.0 source also contains the unguarded await followed by deletion, so the latest supplied release does not contain this repair. (src/index.ts:575, 5e2ccd634980)
  • Previous finding resolved: The README compatibility table now documents waiting, warning once, recovery, and single consumption. Compatibility documentation and the changelog also describe the changed semantics, satisfying the concrete prior finding and repository policy. (README.md:48, 60b6196ff703)
  • Real production-boundary recovery evidence: The captured PR body reports exact-head Python timeout recovery and initialization ordering. The inspected fixtures register the actual production entry, spawn the real Python bridge, inject a two-second start against a 200ms timeout, assert three later turns return 'after timeout', and assert one warning. A separate real-Python fixture asserts a concurrent prepare observes initialized state. These exercise production I/O rather than mocked transport; replacement-race mocks are supplemental. (src/session-start-pending.test.ts:244, 60b6196ff703)
  • Exact-head execution corroboration: GitHub identifies successful run 36846768568 with head_sha 60b6196; its Ubuntu job successfully set up Python, ran checks, and verified package contents. The captured body reports 193 passing tests. Raw job logs redirected to a blocked artifact host, so their detailed transcript could not be independently read; this reviewer limitation does not invalidate the supplied production-path evidence. (60b6196ff703)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-30T23:53:12.234Z sha 7e0aa53 :: needs changes before merge. :: [P3] Document failed session starts in the README compatibility table

@vincentkoc vincentkoc self-assigned this Oct 1, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please review exact head 0533e531877920cc567205a8e2dc2030e2ba9eec.
Scoped maintainer repair preserves original synchronous Hermes start enqueue
and pre-LLM callback ordering, waits for the current pending start without
deleting a replacement, warns once after rejection, and avoids stale context
after end/replacement. Real Python timeout and ordering fixtures, concurrent
prepares, replacement/end races, and successful context isolation are covered.
Focused19/full187/package passed; README compatibility table and credit updated.
All prior findings must be resolved on this head; hosted CI is running.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please review exact head bcaf0658158d8574a035ac76fa79e9d08e949541.
Scoped maintainer repair preserves original synchronous Hermes start enqueue
and pre-LLM callback ordering, waits for the current pending start without
deleting a replacement, warns once after rejection, and avoids stale context
after end/replacement. Persistent owner identity also protects a replacement
from older end/reset cleanup, even after its pending entry has been consumed.
Real Python timeout and ordering fixtures, concurrent
prepares, replacement/end races, and successful context isolation are covered.
Focused23/full191/package passed; README compatibility table and credit updated.
All prior findings must be resolved on this head; hosted CI is running.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit 75d9484 into openclaw:main Oct 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants